(function (doc, win) {
    var docEl = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function () {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
        };
    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);

(function (win, $, selector) {
    $(selector).tap(function () {
        win.history.back();
    });
})(window, Zepto, '#goBack');
(function (win, $, selector) {
    $(selector).focus(function () {
        win.location.href = 'pro_search.html';
    });
})(window, Zepto, '#search');

function Params() {
    var result = {}, hash = location.hash, search = location.search;
    result.docName = decodeURIComponent(location.pathname).match(/\/([^\/]+)\.html$/)[1];//提取文件名
    if (hash) {
        result.hash = hash.replace(/^\#/, ''); //提前锚点
    }
    if (search) {
        var arr = search.replace(/^\?/, '').split(/\&/g); //提前所有search参数
        for (var i = 0, n = arr.length; i < n; i++) {
            var key = arr[i].split(/\=/)[0];
            result[key] = decodeURIComponent(arr[i].split(/\=/)[1]);
        }
    }
    return result;
}

function qingQiuPhp(type, url, data, fun) {
    $.ajax({
        type: type,
        url: url,
        data: data,
        dataType: 'json',
        success: function (res) {
            fun(res);
        }
    })
}

function requestEvent(option, callback) {
    $.ajax({
        type: option.type,
        url: option.url,
        data: option.data,
        dataType: 'json',
        success: function (res) {
            callback(res);
        }
    });
}
